<template>
  <div>
    <van-form @submit="onSubmit">
      <van-field
        v-model="phonenumber"
        name="phonenumber"
        label-width="50"
        label="手机号"
        placeholder="手机号"
        :rules="[
          { required: true, message: '手机号不能为空' },
          { pattern: /^1[3456789]\d{9}$/, message: '请填写正确的手机号' },
        ]"
      />
      <van-field
        v-model="email"
        type="email"
        label-width="50"
        name="email"
        label="邮箱"
        placeholder="邮箱"
        :rules="[
          { required: true, message: '邮箱不能为空' },
          { validator: emailCheck, message: '目前仅支持qq邮箱,请正确填写' },
        ]"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>
<script>
export default {
  name: "",
  data() {
    return {
      phonenumber: "",
      email: "",
    };
  },
  created() {},
  computed: {},
  methods: {
    emailCheck(val) {
      const reg = /^[^@]+@qq\.com$/;
      return reg.test(val);
    },
    onSubmit(values) {
      console.log("submit", values);
    },
  },
};
</script>
<style lang='less'  scoped>
</style>
